package com.ita.iosa.util;

import java.io.IOException;
import java.util.Map;

import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

import vo.Orders;

public class JsonUtil {
	private static ObjectMapper mapper = new ObjectMapper();

	public static String objetc2Json(Object obj) throws JsonProcessingException {
	return mapper.writeValueAsString(obj);
	}

	public static Object json2Object(String json, Class clz)
	throws JsonParseException, JsonMappingException, IOException {
	return mapper.readValue(json, 
			new TypeReference<Map<String, Orders>>(){});
	}
}
